﻿using System;
using System.Collections.Generic;
using System.Text;
using AspNetCs.Enumerations;
using AspNetCs.Model;
using AspNetCs.DALFactory;
using AspNetCs.IDAL;
using AspNetCs.SQLServerDAL;
using System.Data;
using AspNetCs.Common;

namespace AspNetCs.Bll
{
    public class AncestralHallBBSMsg_BLL
    {
        private IAncestralHallBBSMsg Dal = Conn.CreateAncestralHallBBSMsg_DAL();

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AncestralHallBBSMsgModel model)
        {
            return Dal.Add(model);
        }


        public DataTable GetDataTable(string queryProperties, string filter)
        {
            return Dal.GetDataTable(queryProperties,filter);
        }


        public int Delete(string filter)
        {
            return Dal.Delete(filter);
        }

        public AncestralHallBBSMsgModel GetModel(string filter)
        {
            DataTable dataTable = new DataTable(); 
            dataTable = GetDataTable("*", filter);
            AncestralHallBBSMsgModel model = new AncestralHallBBSMsgModel();
            if(dataTable.Rows.Count>0)
            {
                model.Id =StringHelper.isNumber_int(dataTable.Rows[0]["id"].ToString());
                model.AncestralHallItemId = StringHelper.isNumber_int(dataTable.Rows[0]["AncestralHallItemId"].ToString());
                model.Content = dataTable.Rows[0]["Content"].ToString();
                model.PublishTime = StringHelper.isDatetime(dataTable.Rows[0]["PublishTime"].ToString());
                model.Title = dataTable.Rows[0]["Title"].ToString();
                model.UserId = StringHelper.isNumber_int(dataTable.Rows[0]["UserId"].ToString());
                model.Hits = StringHelper.isNumber_int(dataTable.Rows[0]["Hits"].ToString());
            }
            return model;
        }
    }
}
